package com.example.controller;


import com.example.domain.Examination;
import com.example.domain.Medication;
import com.example.dao.MedicationMapper;
import com.example.domain.Prescription2;
import com.example.domain.Record2;
import com.example.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;


/** 试图跳转 */

@Controller
@RequestMapping("/view")
public class ViewController {
    @Autowired
    private PrescriptionService prescriptionService;

    @Autowired
    private PrescriptionService2 prescriptionService2;

    @Autowired
    private MedicationService medicationService;

    @Autowired
    private ExaminationService examinationService;


    @Autowired
    private RecordService2 recordService2;

    @Autowired
    private CheckInService checkInService;

    @GetMapping("/welcome_patient")
    public String welcome1() {
        return "page/welcome_patient";
    }
    /** 处方情况 */
    @GetMapping("/prescription")
    public String prescription(){
        return "page/prescription";
    }
    /** 处方情况 */
    @GetMapping("/prescription2")
    public String prescription2(){
        return "page/prescription2";
    }

    @GetMapping("/examination")
    public String examination(){
        return "page/examination";
    }

    @GetMapping("/examination2")
    public String examination2(){
        return "page/examination2";
    }

    @GetMapping("/record")
    public String record(){
        return "page/record";
    }

    @GetMapping("/record2")
    public String record2(){
        return "page/record2";
    }

    /** 预约情况 */
    @GetMapping("/reservation")
    public String reservation(){ return "page/reservation"; }

    /** 排队叫号 */
    @GetMapping("/call")
    public String queue(){ return "page/call"; }

    @GetMapping("/patient")
    public String patient(){
        return "page/patient";
    }

    @GetMapping("/charge")
    public String charge(){
        return "page/charge";
    }

    /** 药品管理 */
    @GetMapping("/medication")
    public String medication(){
        return "page/medication";
    }

    /** 检验状态 */
    @GetMapping("/checkIn")
    public String checkIn(){
        return "page/checkIn";
    }

    /** 处方信息 */
    @GetMapping("/catering")
    public String catering(){
        return "page/catering";
    }

    /** 挂号排队 */
    @GetMapping("/visitor")
    public String visitor(){ return "page/visitor"; }

    /** 缴费管理 */
    @GetMapping("/accident")
    public String accident(){
        return "page/accident";
    }

    /** 添 加 药 品 */
    @GetMapping("/addMedication")
    public String addMedication(){
        return "page/add/addMedication";
    }

    /** 添 加 病 例 */
    @GetMapping("/addRecord")
    public String addRecord(){
        return "page/add/addRecord";
    }

    /** 添 加 检 查 */
    @GetMapping("/addExam")
    public String addExam(){
        return "page/add/addExam";
    }

    /** 添加处方 */
    @GetMapping("/addPrescription")
    public String addPrescription(){
        return "page/add/addPrescription";
    }




    /** 添加检查信息 */
    @GetMapping("/addCheck")
    public String addCheck(){
        return "page/add/addCheckIn";
    }

    /** 添 加 排队患者 */
    @GetMapping("/addVis")
    public String addVisitor(){ return "page/add/addVisitor"; }

    @GetMapping("/addVis1")
    public String addVisitor1(){ return "page/add/addVisitor1"; }

    /** 修 改 药品信息 */
    @GetMapping("/modifyMedication")
    public String modifyMedication(@RequestParam(value = "id") long id,
                                   Model model){
        Medication medication = medicationService.getById(id);
        model.addAttribute("medication",medication);
        return "page/modify/modifyMedication";
    }

    /** 修改病例信息 */
    @GetMapping("/modifyRecord")
    public String modifyRecord(@RequestParam(value = "id") int id,
                               Model model){
        Record2 record2 = recordService2.getById(id);
        model.addAttribute("record2",record2);
        return "page/modify/modifyRecord";
    }

    /** 修改检验信息
     * @return*/
    @GetMapping("/modifyExam")
    public String modifyExam(@RequestParam(required=false) int id,
                             Model model){
        Examination examination = examinationService.getById(id);
        model.addAttribute("examination",examination);
        return "page/modify/modifyExam";
    }

    /** 修改处方信息 */
    @GetMapping("/modifyPrescription")
    public String modifyPrescription(@RequestParam(value = "id") int id,
                                     Model model){
        Prescription2 prescription2 = prescriptionService2.getById(id);
        model.addAttribute("prescription2",prescription2);
        return "page/modify/modifyPrescription";
    }




}
